package com.ruoyi.web.controller.mes;

import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.web.service.MesProducePieceMachineService;
import com.ruoyi.web.service.ProducePieceService;
import com.ruoyi.web.service.ProduceService;
import com.ruoyi.web.vo.MesProducePieceMachine;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.web.domain.MesTakeVersion;
import com.ruoyi.web.service.IMesTakeVersionService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 取版Controller
 * 
 * @author wxt
 * @date 2024-02-20
 */
@Api("取版管理")
@RestController
@RequestMapping("/mes/take/version")
public class MesTakeVersionController extends BaseController
{
    @Autowired
    private IMesTakeVersionService mesTakeVersionService;

    @Resource
    private ProducePieceService producePieceService;

    @Resource
    private ProduceService produceService;

    @Resource
    private MesProducePieceMachineService mesProducePieceMachineService;
    /**
     * 查询取版列表
     */
    @ApiOperation("查询取版列表")
    @GetMapping("/list")
    public TableDataInfo list(MesTakeVersion mesTakeVersion)
    {
        startPage();
        List<MesTakeVersion> list = mesTakeVersionService.selectMesTakeVersionList(mesTakeVersion);
        return getDataTable(list);
    }

    /**
     * 导出取版列表
     */
    @Log(title = "取版", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MesTakeVersion mesTakeVersion)
    {
        List<MesTakeVersion> list = mesTakeVersionService.selectMesTakeVersionList(mesTakeVersion);
        ExcelUtil<MesTakeVersion> util = new ExcelUtil<MesTakeVersion>(MesTakeVersion.class);
        util.exportExcel(response, list, "取版数据");
    }

    /**
     * 获取取版详细信息
     */
    @ApiOperation("获取取版详细信息")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(mesTakeVersionService.selectMesTakeVersionById(id));
    }


    @ApiOperation("获取取版详细信息")
    @GetMapping("/VersionDetaillist")
    public AjaxResult VersionDetaillist()
    {
        startPage();
        return success(mesTakeVersionService.VersionDetaillist());
    }

    /**
     * 新增取版
     */
    @ApiOperation("新增取版")
    @Log(title = "取版", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MesTakeVersion mesTakeVersion)
    {
        return mesTakeVersionService.insertMesTakeVersion(mesTakeVersion);
    }

    /**
     * 修改取版
     */
    @ApiOperation("修改取版")
    @Log(title = "取版", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MesTakeVersion mesTakeVersion)
    {
        return toAjax(mesTakeVersionService.updateMesTakeVersion(mesTakeVersion));
    }

    /**
     * 删除取版
     */
    @ApiOperation("删除取版")
    @Log(title = "取版", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(mesTakeVersionService.deleteMesTakeVersionByIds(ids));
    }
}
